//
//  TaskAssignDetailViewController.m
//  Conference
//
//  Created by Xiang He on 12-11-19.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "TaskAssignDetailViewController.h"
#import "Globals.h"
#import "NetContant.h"
#import "AsyncImageView.h"
@interface TaskAssignDetailViewController ()

@end

@implementation TaskAssignDetailViewController
@synthesize lab_title;
@synthesize lab_time;
@synthesize lab_content;
@synthesize activitiesData;
@synthesize Height;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{  [super viewDidLoad];
    self.lab_title.text=self.activitiesData.title;
    self.lab_time.text=[NSString stringWithFormat:@"更新时间:%@",self.activitiesData.dateTime];;
    
    NSString *content=self.activitiesData.message;
    
    UIFont *font = [UIFont systemFontOfSize:16];
    
    CGSize size=[[Globals getInstance]CalculationCellSize:self.view.frame.size.width fontSize:16 content:content];
    
    CGRect rect = [self.lab_content textRectForBounds:self.lab_content.frame limitedToNumberOfLines:0];
    rect.size=size;
    self.lab_content.frame = rect;
    self.lab_content.text=content;
    self.lab_content.numberOfLines = 0;
    self.lab_content.font = font;
    
    
    self.Height=150+size.height;
    NSString *imgUri=self.activitiesData.urlPhoto;
    
    if(nil!=imgUri||![imgUri isEqualToString:@""]){
        NSArray *img=[imgUri componentsSeparatedByString:[NetContant getInstance].IMGURL_SPLIT_FLAG];
        for(int i=0;i<[img count];i++){
            NSString *sImg=[img objectAtIndex:i];
            if (nil == sImg || [@"" isEqualToString:sImg])
                continue;
            AsyncImageView *asyncImage = [[AsyncImageView alloc] init];
            asyncImage.frame = CGRectMake(100, self.Height, 95, 95);
            [asyncImage loadImageFromURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",[Globals getInstance].servierUrl,sImg]]];
            self.Height=self.Height+asyncImage.frame.size.height;
            [self.view addSubview:asyncImage];
            [asyncImage release];
        }
    
    }

    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [self setLab_title:nil];
    [self setLab_time:nil];
    [self setLab_content:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)dealloc {
    [lab_title release];
    [lab_time release];
    [lab_content release];
    [super dealloc];
}
- (IBAction)btnBackAction:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
@end
